#pragma once

#include "udp_socket.hpp"

class udpclient
{
public:
    udpclient(const std::string& ip, uint16_t port):ip_(ip),port_(port)
    {
        assert(sock_.Socket());
    }
    ~udpclient(){
        sock_.Close();
    }
    bool Recvfrom(std::string *buf)
    {
        return sock_.RevcFrom(buf);
    }
    bool Sendto(const std::string& buf)
    {
        return sock_.SendTo(buf, ip_, port_);
    }
private:
    udpsocket sock_;
    std::string ip_;
    uint16_t port_;
};